/*
 * @lc app=leetcode.cn id=268 lang=javascript
 *
 * [268] 丢失的数字
 */

// @lc code=start
/**
 * @param {number[]} nums
 * @return {number}
 */
var missingNumber = function (nums) {
  let res = 0;
  const len = nums.length;
  for (let i = 0; i < len; i++) {
    res ^= nums[i];
  }
  for (let i = 0; i <= len; i++) {
    res ^= i;
  }
  return res;
};
// @lc code=end
